package io.github.wanggit.antrpc.gateway.starter;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.event.SimpleApplicationEventMulticaster;
import org.springframework.stereotype.Component;

@Component
public class EventMulticasterBeanPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName)
            throws BeansException {
        if (bean instanceof SimpleApplicationEventMulticaster) {
            ((SimpleApplicationEventMulticaster) bean).setTaskExecutor(null);
        }
        return bean;
    }
}
